package robotutils.planning;

import java.io.Serializable;

/**
 * A tuple with two components used to assign priorities to states in the
 * D* search.  Keys are compared according to a lexical ordering, e.g.
 * k &lt k' iff either k1 &lt k'1 or (k1 = k'1 and k2 &lt k'2).
 */
final class Key implements Comparable<Key>, Serializable {
    
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	final double a;
    final double b;

    public Key(double a, double b) {

        this.a = a;
        this.b = b;
    }

    public int compareTo(Key that) {

        if (this.a < that.a) {
            return -1;
        } else if (this.a > that.a) {
            return 1;
        } else {
            if (this.b < that.b) {
                return -1;
            } else if (this.b > that.b) {
                return 1;
            } else {
                return 0;
            }
        }
    }

    @Override
    public String toString() {
        return "<" + a + "," + b + ">";
    }
}